<template>
  <div class="table-box">
    <div class="table">
      <div
        class="item"
        v-for="item in items"
        :key="item.fileId"
        @click="goDetail(item.fileId)"
      >
        <img :src="getFileIcon(item.fileSuffix)" />
        {{ item.fileName }}
      </div>
    </div>
    <!-- <button>查看更多 >></button> -->
  </div>
</template>

<script>
export default {
  props: {
    items: { required: true, type: Array },
  },
  data() {
    return {};
  },
  methods: {
    goDetail(fileId) {
      this.$router.push({
        path: "/docdetail",
        query: {
          id: fileId,
        },
      });
    },
    //根据文件类型显示不同图标
    getFileIcon(type) {
      switch (type) {
        case "doc":
          return require("@/assets/image/common/fileIcon/file-word.png");
        case "docx":
          return require("@/assets/image/common/fileIcon/file-word.png");
        case "pdf":
          return require("@/assets/image/common/fileIcon/file-pdf.png");
        case "txt":
          return require("@/assets/image/common/fileIcon/file-text.png");
        case "xlsx":
          return require("@/assets/image/common/fileIcon/file-excel.png");
        case "ppt":
          return require("@/assets/image/common/fileIcon/file-ppt.png");
        case "pptx":
          return require("@/assets/image/common/fileIcon/file-ppt.png");
        case "rar":
          return require("@/assets/image/common/fileIcon/file-zip.png");
        case "zip":
          return require("@/assets/image/common/fileIcon/file-zip.png");
      }
    },
  },
};
</script>

<style scoped>
.table {
  width: 100%;
  height: 300px;
  overflow-y: scroll;
  max-height: 300px;
  background-color: white;
  border-bottom: 1px solid rgb(209, 219, 229);
}
.item {
  cursor: pointer;
  height: 40px;
  width: 144px;
  line-height: 40px;
  font-size: 14px;
  color: rgb(100, 100, 100);
  word-break: break-all;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  padding-left: 10px;
}
.item:hover {
  color: #005a95;
}
img {
  display: inline-block;
  width: 20px;
  height: 20px;
  vertical-align: middle;
  margin-right: 3px;
}
.item > div {
  display: inline-block;
  height: 30px;
  width: 144px;
  line-height: 30px;
}
button {
  cursor: pointer;
  background-color: white;
  color: rgb(100, 100, 100);
  border: none;
  float: right;
  padding-right: 10px;
}
button:hover {
  color: #005a95;
}
.table-box {
  width: 100%;
  height: 320px;
  background-color: white;
}
</style>
